<template>
	<view class="container">
	<uni-section title="图片" sub-title="" type="line">
		<image :src="'http://localhost:8090'+data.icon" style="width: 100%;" mode="aspectFit"></image>
	</uni-section>
	<uni-section title="名称" sub-title="" type="line">
		{{data.name}}
	</uni-section>
	<uni-section title="类别" sub-title="" type="line">
		{{data.type}}
	</uni-section>
	<uni-section title="价格" sub-title="" type="line">
		{{data.price}}
	</uni-section>
	<uni-section title="描述" sub-title="" type="line">
		{{data.description}}
	</uni-section>
	<uni-section title="" sub-title="" type="" >
		<view style="display: flex;">
			<uni-easyinput v-model="comment"  placeholder="请输入评论内容" />
			
			<button type="default" size="mini" @click="issue(data.id)">发表</button></view>
	</uni-section>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:{},
				comment:""
			}
		},
		methods: {
issue(id){
	uni.request({
		url: 'http://localhost:8090/foodapp/comment/addone',
		method: 'POST',
		data: {
			 "foodid": id,
			 "userid": 1,
			"comment": this.comment,
			 "postdate": "2022-09-09"
		},
		success: res => {
			if(res.data.success){
				uni.showToast({
					title: '评论发表成功',
					icon:'none'
				});
			}
		},
		fail: () => {},
		complete: () => {}
	});
}
		},
		onLoad(e) {
			uni.request({
				url: 'http://localhost:8090/foodapp/food/findone',
				method: 'POST',
				data: {id:e.id},
				success: res => {
					this.data=res.data.data
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
